package com.tom.architect.party4.day33;

import androidx.appcompat.app.AppCompatActivity;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;

import com.tom.architect.R;
import com.tom.architect.party4.day33.simple2.HttpCallback;
import com.tom.architect.party4.day33.simple2.Result;
import com.tom.architect.party4.day33.simple2.RetrofitClient;
import com.tom.architect.party4.day33.simple2.UserInfo;
import com.tom.architect.party4.day33.simple2.UserLoginResult;


/**
 * 2.data是不同的类型。成功data是对象；不成功data是个String
 * 3.baseUrl。不同的baseUrl构建不同的Retrofit？
 */
public class MainActivity33 extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main33);

        // data是不同的类型。

        Call<Result<UserInfo>> call = RetrofitClient.getServiceApi().userLogin("Tom", "123456");
        call.enqueue(new HttpCallback<UserInfo>() {
            @Override
            protected void onSucceed(UserInfo result) {
                // 登录成功的场景，登录失败都进入onError回调。
                Toast.makeText(MainActivity33.this, "成功了：" + result.toString(), Toast.LENGTH_SHORT).show();
            }

            @Override
            protected void onError(String code, String msg) {
                Toast.makeText(MainActivity33.this, "msg", Toast.LENGTH_SHORT).show();
            }
        });

    }


}